// 20140922002.cpp : 定义控制台应用程序的入口点。
//
 
// #include "stdafx.h"
// #include "glut.h"
#include <GL/glut.h>
 
 int frame=0,time=0,timebase=0; 
void ShowFrameRate()
{
    char s[100]={0};
    frame++;
    time=glutGet(GLUT_ELAPSED_TIME);
    if (time - timebase > 1000) {
        sprintf(s,"FPS:%4.2f",
            frame*1000.0/(time-timebase));
        timebase = time;
        frame = 0;
        printf("帧率为：%d\n",s);
    }
}

void display(void){
	glColor3f(1.0,1.0,1.0);
	glDisable(GL_DEPTH_TEST);
	glBegin(GL_POLYGON);
		glVertex3f(0.25,0.25,0.0);
		glVertex3f(0.75,0.25,0.0);
		glVertex3f(0.75,0.75,0.0);
		glVertex3f(0.25,0.75,0.0);
	glEnd();
 
	glFlush();
}
 
void init(void){
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}
 
int main(int argc, char* argv[])
{
	glutInit(&argc,argv);

	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
	glutInitWindowSize(250,250);
	glutInitWindowPosition(100,100);
	glutCreateWindow("Hello World");
	init();
	glutDisplayFunc(display);
	// for(;;)
	// ShowFrameRate();
	glutMainLoop();
	return 0;
}
